<template>
	<view class="bg-white">
		<view v-for="(item,index) in addressList" :key="index">
			<view @tap="selectItem(item)" style="padding: 20upx;" class="text-black">
				<view style="margin-top: 30upx;margin-left: 10upx;font-size: 80%;">
					<text v-if="item.defaultStatus == 1" class="cu-tag bg-red round">默认</text>
					<text style="margin-left: 2upx; font-size: 120%;">{{item.province}}</text>
					<text>{{item.city}}</text>
				</view>
				<view class="flex justify-between" style="padding: 10upx;" @tag="select">
					<view class="text-bold text-lg">{{item.detailAddress}}</view>
					<view><text class="cuIcon-right"></text></view>
				</view>
				<view style="margin-left: 20upx;font-size: 80%;">
					<text>{{item.name}}</text>
					<text style="margin-left: 50upx;">{{item.phone}}</text>
				</view>
			</view>
		</view>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				addressList:[],
				memberId:'',
				orderList:[],
				userInfo:{}
			}
		},
		onLoad(options){
			this.orderList = JSON.parse(decodeURIComponent(options.orderInfo))
			this.userInfo = JSON.parse(decodeURIComponent(options.userInfo))	
			this.getAddressList()
		},
		methods: {
			async getAddressList(){
				var that = this
				var res = await this.$request({
					url:`member/memberreceiveaddress/${that.userInfo.id}/addresses`,
					params:{},
					type:'GET'
				})
				this.addressList = res
			},
			selectItem(item) {
				uni.navigateTo({
					url:`../order/orderDetails?orderInfo=${encodeURIComponent(JSON.stringify(this.orderList))}&userInfo=${encodeURIComponent(JSON.stringify(this.userInfo))}
					&userAddress=${encodeURIComponent(JSON.stringify(item))}`
				})
			}
		}
	}
</script>

<style>
	.barfixed {
		position: fixed;
		bottom: 0upx;
		width: 750upx; }
		
</style>
